{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "def uniquePaths(m: int, n: int) -> int:\n",
    "    # 初始化动态规划数组，\n",
    "    # 只能向下，向右走，故第一行，第一列置为1\n",
    "    dp = [[1]*n] + [[1]+[0]*(n-1)for _ in range(m-1)]\n",
    "\n",
    "    for i in range(1,m):\n",
    "        for j in range(1,n):\n",
    "            # 动态转移数组，当前状态由左边的+上边的状态决定。\n",
    "            dp[i][j] = dp[i-1][j] + dp[i][j-1]\n",
    "            for item in dp:\n",
    "                print(item)\n",
    "            print()\n",
    "    return dp[-1][-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 1, 1, 1, 1, 1, 1]\n",
      "[1, 2, 0, 0, 0, 0, 0]\n",
      "[1, 0, 0, 0, 0, 0, 0]\n",
      "\n",
      "[1, 1, 1, 1, 1, 1, 1]\n",
      "[1, 2, 3, 0, 0, 0, 0]\n",
      "[1, 0, 0, 0, 0, 0, 0]\n",
      "\n",
      "[1, 1, 1, 1, 1, 1, 1]\n",
      "[1, 2, 3, 4, 0, 0, 0]\n",
      "[1, 0, 0, 0, 0, 0, 0]\n",
      "\n",
      "[1, 1, 1, 1, 1, 1, 1]\n",
      "[1, 2, 3, 4, 5, 0, 0]\n",
      "[1, 0, 0, 0, 0, 0, 0]\n",
      "\n",
      "[1, 1, 1, 1, 1, 1, 1]\n",
      "[1, 2, 3, 4, 5, 6, 0]\n",
      "[1, 0, 0, 0, 0, 0, 0]\n",
      "\n",
      "[1, 1, 1, 1, 1, 1, 1]\n",
      "[1, 2, 3, 4, 5, 6, 7]\n",
      "[1, 0, 0, 0, 0, 0, 0]\n",
      "\n",
      "[1, 1, 1, 1, 1, 1, 1]\n",
      "[1, 2, 3, 4, 5, 6, 7]\n",
      "[1, 3, 0, 0, 0, 0, 0]\n",
      "\n",
      "[1, 1, 1, 1, 1, 1, 1]\n",
      "[1, 2, 3, 4, 5, 6, 7]\n",
      "[1, 3, 6, 0, 0, 0, 0]\n",
      "\n",
      "[1, 1, 1, 1, 1, 1, 1]\n",
      "[1, 2, 3, 4, 5, 6, 7]\n",
      "[1, 3, 6, 10, 0, 0, 0]\n",
      "\n",
      "[1, 1, 1, 1, 1, 1, 1]\n",
      "[1, 2, 3, 4, 5, 6, 7]\n",
      "[1, 3, 6, 10, 15, 0, 0]\n",
      "\n",
      "[1, 1, 1, 1, 1, 1, 1]\n",
      "[1, 2, 3, 4, 5, 6, 7]\n",
      "[1, 3, 6, 10, 15, 21, 0]\n",
      "\n",
      "[1, 1, 1, 1, 1, 1, 1]\n",
      "[1, 2, 3, 4, 5, 6, 7]\n",
      "[1, 3, 6, 10, 15, 21, 28]\n",
      "\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "28"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "uniquePaths(3,7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "([[1, 1, 1]], [1, 1, 1])"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[[1]*3], [1]*3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 0, 0]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[1]+[0]*(3-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[[1, 0, 0], [1, 0, 0], [1, 0, 0], [1, 0, 0], [1, 0, 0], [1, 0, 0], [1, 0, 0]]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[[1]+[0]*(3-1)for _ in range(8-1)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[[1, 0, 0],\n",
       " [1, 0, 0],\n",
       " [1, 0, 0],\n",
       " [1, 0, 0],\n",
       " [1, 0, 0],\n",
       " [1, 0, 0],\n",
       " [1, 0, 0],\n",
       " [1, 1, 1]]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[[1]+[0]*(3-1)for _ in range(8-1)] + [[1]*3]"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
